<?php
declare (strict_types=1);

namespace Plugin\Device\Model;

use Mine\MineModel;
use Plugin\File\Model\RdFileVoice;
use Plugin\Organization\Model\RdOrganizeAreaStand;

class RdDeviceSerial extends MineModel
{
    /**
     * The table associated with the model.
     *
     * @var string|null
     */
    protected ?string $table = 'rd_device_serial';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected array $fillable = [
        'id', 'rod_id', 'online', 'name', 'voice_id', 'comply_id', 'url', 'device_serial', 'channel_no', 'type', 'stand_id', 'sort', 'remarks', 'prompt_id', 'addr', 'created_at', 'updated_at', 'deleted_at', 'created_by', 'updated_by'
    ];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected array $casts = [
        'id' => 'integer',
        'rod_id' => 'integer',
        'online' => 'integer',
        'voice_id' => 'integer',
        'comply_id' => 'integer',
        'type' => 'integer',
        'stand_id' => 'integer',
        'sort' => 'integer',
        'prompt_id' => 'integer',
        'created_by' => 'integer',
        'updated_by' => 'integer',
        'created_at' => 'datetime',
        'updated_at' => 'datetime',
        'deleted_at' => 'datetime',
        'url' => 'array',
    ];

    public function rod()
    {
        return $this->belongsTo(RdDeviceRod::class, 'rod_id', 'id');
    }

    public function stand()
    {
        return $this->belongsTo(RdOrganizeAreaStand::class, 'stand_id', 'id');
    }

    public function voice()
    {
        return $this->belongsTo(RdFileVoice::class, 'voice_id', 'id');
    }

    public function comply()
    {
        return $this->belongsTo(RdFileVoice::class, 'comply_id', 'id');
    }
    
}